package pcjavanet.mobilesell.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import pcjavanet.mobilesell.model.Member;
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.service.MemberService;

import com.opensymphony.xwork2.ActionSupport;
@Namespace("/member")
@Controller
@Scope("prototype")
@ParentPackage("json-default")
@Results({
	@Result(name = "success", location = "/view/Member.jsp"),
	@Result(name = "input", location = "/view/Member.jsp")
})

public class MemberAction  extends ActionSupport {

  @Resource
  private MemberService memberService;
  private   java.lang.Integer dbid ;
  private   java.lang.String cardnumber ;
  private   java.lang.String name ;
  private   java.lang.Integer refAreaDbid ;
  private   java.lang.String sex ;
  private   java.util.Date joinDate ;
  private   java.lang.Integer jifen ;
  private   java.lang.String telnumber ;
  private   java.lang.String mobile ;
  private   java.lang.String email ;
  private   java.lang.String zipcode ;
  private   java.util.Date createDate ;
  private int start  ;
  private int limit  ;
  private int totalProperty  ;
  private boolean success = true ;
  private String  info ;
  private List<Member>  memberPageBeans  ;
  public    java.lang.Integer getDbid() {
   	return this.dbid;
  }
  public void setDbid(  java.lang.Integer  dbid) {
   	 this.dbid=dbid;
  }
  public    java.lang.String getCardnumber() {
   	return this.cardnumber;
  }
  public void setCardnumber(  java.lang.String  cardnumber) {
   	 this.cardnumber=cardnumber;
  }
  public    java.lang.String getName() {
   	return this.name;
  }
  public void setName(  java.lang.String  name) {
   	 this.name=name;
  }
  public    java.lang.Integer getRefAreaDbid() {
   	return this.refAreaDbid;
  }
  public void setRefAreaDbid(  java.lang.Integer  refAreaDbid) {
   	 this.refAreaDbid=refAreaDbid;
  }
  public    java.lang.String getSex() {
   	return this.sex;
  }
  public void setSex(  java.lang.String  sex) {
   	 this.sex=sex;
  }
  public    java.util.Date getJoinDate() {
   	return this.joinDate;
  }
  public void setJoinDate(  java.util.Date  joinDate) {
   	 this.joinDate=joinDate;
  }
  public    java.lang.Integer getJifen() {
   	return this.jifen;
  }
  public void setJifen(  java.lang.Integer  jifen) {
   	 this.jifen=jifen;
  }
  public    java.lang.String getTelnumber() {
   	return this.telnumber;
  }
  public void setTelnumber(  java.lang.String  telnumber) {
   	 this.telnumber=telnumber;
  }
  public    java.lang.String getMobile() {
   	return this.mobile;
  }
  public void setMobile(  java.lang.String  mobile) {
   	 this.mobile=mobile;
  }
  public    java.lang.String getEmail() {
   	return this.email;
  }
  public void setEmail(  java.lang.String  email) {
   	 this.email=email;
  }
  public    java.lang.String getZipcode() {
   	return this.zipcode;
  }
  public void setZipcode(  java.lang.String  zipcode) {
   	 this.zipcode=zipcode;
  }
  public    java.util.Date getCreateDate() {
   	return this.createDate;
  }
  public void setCreateDate(  java.util.Date  createDate) {
   	 this.createDate=createDate;
  }
  public  void setStart(int start) {
   	 this.start = start;
  }
  public  void setLimit(int limit) {
   	 this.limit = limit;
  }
  public  void setTotalProperty(int totalProperty) {
   	 this.totalProperty = totalProperty;
  }
  public  void setMemberPageBeans(List<Member> memberPageBeans){
   	 this.memberPageBeans =memberPageBeans  ;
  }
  public  int getStart( ) {
   	 return this.start;
  }
  public  int getLimit( ) {
   	 return this.limit;
  }
  public  int getTotalProperty( ) {
   	 return this.totalProperty;
  }
  public    List<Member> getMemberPageBeans(){
   	 return this.memberPageBeans   ;
  }
  public  String getInfo( ) {
   	 return this.info;
  }
  public  void setInfo(String info){
   	 this.info = info ;
  }
  public  boolean getSuccess( ) {
   	 return this.success;
  }
  public  void setSuccess(boolean success){
   	 this.success = success ;
  }

  @Action(value="insertMember",results = {@Result(name = "success", type = "json")})
  public String  insertMember() throws Exception{
   	success = false ;
   	info = "" ;
  	Member bean = new Member();
  	bean.setCardnumber(this.cardnumber); 
  	bean.setName(this.name); 
  	bean.setRefAreaDbid(this.refAreaDbid); 
  	bean.setSex(this.sex); 
  	bean.setJoinDate(this.joinDate); 
  	bean.setJifen(this.jifen); 
  	bean.setTelnumber(this.telnumber); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setCreateDate(this.createDate); 
	memberService.insert(bean);
   	success = true ;
   	info = "Add Successful" ;
   	return SUCCESS;
  }

  @Action(value="queryMember",results = {@Result(name = "success", type = "json")})
  public String  queryMember() throws Exception{
  	Member bean = new Member();
  	bean.setDbid(this.dbid); 
  	bean.setCardnumber(this.cardnumber); 
  	bean.setName(this.name); 
  	bean.setRefAreaDbid(this.refAreaDbid); 
  	bean.setSex(this.sex); 
  	bean.setJoinDate(this.joinDate); 
  	bean.setJifen(this.jifen); 
  	bean.setTelnumber(this.telnumber); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setCreateDate(this.createDate); 
	memberService.selectByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="updateMember",results = {@Result(name = "success", type = "json")})
  public String  updateMember() throws Exception{
   	success = false ;
   	info = "" ;
  	Member bean = new Member();
  	bean.setDbid(this.dbid); 
  	bean.setCardnumber(this.cardnumber); 
  	bean.setName(this.name); 
  	bean.setRefAreaDbid(this.refAreaDbid); 
  	bean.setSex(this.sex); 
  	bean.setJoinDate(this.joinDate); 
  	bean.setJifen(this.jifen); 
  	bean.setTelnumber(this.telnumber); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setCreateDate(this.createDate); 
  	bean =memberService.selectByPrimaryKey(bean);
  	bean.setDbid(this.dbid); 
  	bean.setCardnumber(this.cardnumber); 
  	bean.setName(this.name); 
  	bean.setRefAreaDbid(this.refAreaDbid); 
  	bean.setSex(this.sex); 
  	bean.setJoinDate(this.joinDate); 
  	bean.setJifen(this.jifen); 
  	bean.setTelnumber(this.telnumber); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setCreateDate(this.createDate); 
	memberService.updateByPrimaryKeySelective(bean);
   	success = true ;
   	info = "Update Successful" ;
   	return SUCCESS;
  }

  @Action(value="deleteMember",results = {@Result(name = "success", type = "json")})
  public String  deleteMember() throws Exception{
  	Member bean = new Member();
  	bean.setDbid(this.dbid); 
  	bean.setCardnumber(this.cardnumber); 
  	bean.setName(this.name); 
  	bean.setRefAreaDbid(this.refAreaDbid); 
  	bean.setSex(this.sex); 
  	bean.setJoinDate(this.joinDate); 
  	bean.setJifen(this.jifen); 
  	bean.setTelnumber(this.telnumber); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setCreateDate(this.createDate); 
	memberService.deleteByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="listMember",results = {@Result(name = "success", type = "json")})
  public String  listMember() throws Exception{
 	QryCondition qry = RequestUtil.getQryCondition(   (javax.servlet.http.HttpServletRequest)com.opensymphony.xwork2.ActionContext.getContext().get(org.apache.struts2.ServletActionContext.HTTP_REQUEST)); 	PageBean pageBean = new PageBean();
	pageBean.setPageSize( limit );
	pageBean.setStartCount( start );
	totalProperty =memberService.getTotalRecords( qry, pageBean );
	memberPageBeans =memberService.getOnePageBeans( qry, pageBean );
   	return SUCCESS;
  }

  @Action("index")
  public String index() throws Exception{
   	return SUCCESS;
  }
}
